//
//  AdressViewController.m
//  智慧小区
//
//  Created by 高永杨 on 2017/3/18.
//  Copyright © 2017年 zhongchuang. All rights reserved.
//

#import "AdressViewController.h"
#import "AdressViewCell.h"
#import "AdressViewDetailVC.h"

@interface AdressViewController ()<UITableViewDelegate,UITableViewDataSource,AdressCellDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableV;
/**<#参数意思#>*/
@property(nonatomic,weak)UIButton *select;
@end

@implementation AdressViewController


static  NSString *cellAdressId = @"cellAdressId";

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableV registerNib:[UINib nibWithNibName:NSStringFromClass([AdressViewCell class]) bundle:nil] forCellReuseIdentifier:cellAdressId];
    self.navigationItem.title = @"地址管理";
    self.tabBarController.tabBar.hidden = YES;
    [self setNav:self];
    // Do any additional setup after loading the view from its nib.
}
-(void)goBack
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)sendDelegateData:(UIButton *)sender
{
    NSString *tempSTr = sender.currentTitle;
    if ([tempSTr isEqualToString:@"默认地址"]) {
        AdressViewCell *cell = (AdressViewCell *)[[sender superview] superview].superview;
        [(UIButton *)[cell viewWithTag:500] setSelected:YES];

    }
    else if ([tempSTr isEqualToString:@"编辑"]){
        [self goToAdreeV];
    }
    else if ([tempSTr isEqualToString:@"删除"]){
    
    
    }
}
-(void)goToAdreeV
{
    AdressViewDetailVC *adressDetail = [[AdressViewDetailVC alloc]init];
    [self.navigationController pushViewController:adressDetail animated:YES];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AdressViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellAdressId forIndexPath:indexPath];
    cell.delegate = self;
    return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 120;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

}
- (IBAction)createNewAdress:(UIButton *)sender {
    [self goToAdreeV];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
